package net;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class TestServer {
	@SuppressWarnings("resource")
	public static void main(String[] args) throws Exception{
		ServerSocket server = new ServerSocket(8888);
		while(true){
		Socket socket = null;
		socket = server.accept();
		System.out.println("One client connecte.....");
		OutputStream out = socket.getOutputStream();
		InputStream in = socket.getInputStream();
		BufferedReader reader = new BufferedReader(new InputStreamReader(in));
		out.write("please input your encodding:\n".getBytes("gbk"));
		String encodding = reader.readLine();
		out.write("hello I am 吴渊".getBytes(encodding));
		out.close();
		socket.close();
		}
	}
}
